package com.fhz.module_main.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.fhz.module_main.databinding.RecommendFollowCardLayoutBinding
import com.fhz.module_main.databinding.RecommendTextCardLayoutBinding
import com.fhz.module_main.entity.RecommendEntity
import com.fhz.module_main.entity.TextCard

/**
 * 时间:2023/5/10
 * @author Mr.Feng
 * 简述: TODO
 */
class RecommendFollowCardAdapter : BaseQuickAdapter<RecommendEntity.Data, RecommendFollowCardAdapter.VH>() {

    // 自定义ViewHolder类
    class VH(
        parent: ViewGroup,
        val binding: RecommendFollowCardLayoutBinding = RecommendFollowCardLayoutBinding.inflate(
            LayoutInflater.from(parent.context), parent, false
        ),
    ) : RecyclerView.ViewHolder(binding.root)

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
        // 返回一个 ViewHolder
        return VH(parent)
    }

    override fun onBindViewHolder(holder: VH, position: Int, item: RecommendEntity.Data?) {
        // 设置item数据
        if (item != null){
            holder.binding.tvTitle.text = item.content.data.title
            holder.binding.tvDescription.text = item.content.data.category
            Glide.with(context).load(item.content.data.cover.feed).into(holder.binding.ivVideoCover)
            Glide.with(context).load(item.header.icon).into(holder.binding.ivAuthor)
        }
    }

}